<?php

include ("../lib/BLL/DonViBLL.php");
include ("../lib/BLL/DmNganhBLL.php");
include ("../lib/BLL/KhoaHocBLL.php");
include ("../lib/BLL/SinhVienLopBLL.php");

$thongbao="";
$donvi=new DonViBLL();
$nganh=new DmNganhBLL();
$khoahoc= new KhoaHocBLL();
$lopsvDAL=new SinhVienLop();
$lopsvBLL=new SinhVienLopBLL();

//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
 if(isset($_POST['luu'])){
        $ngaybatdau=$_POST['ngaybd'];
        $ma_lop=$_POST['lop'];
        $svadd = preg_split("/,/",$_POST['push']);
        $svdel = preg_split("/,/",$_POST['pop']);
        foreach($svadd as $ma_nhaphoc){
              $lopsvDAL->setSVLop($ma_nhaphoc,$ma_lop,$ngaybatdau);
              $kq=$lopsvBLL->insertLopSinhVien($lopsvDAL);   
        }
        foreach($svdel as $ma_nhaphoc){
              $kq=$lopsvBLL->deleteLopSVbyID($ma_nhaphoc);      
        }
  }


$smarty->assign('thongbao',$thongbao);  
$ds_donvi=$donvi->getListDonVi_Lienket();
$smarty->assign('ds_donvi',$ds_donvi);

$ds_nganh= $nganh->getListNganh();
$smarty->assign('ds_nganh',$ds_nganh);

$so_nganh= $nganh->countNganh();
$smarty->assign('so_nganh',$so_nganh);

$ngayhientai= date('d/m/Y');
$smarty->assign('ngayhientai',$ngayhientai);

$ds_namkhoahoc=$khoahoc->getListNamKhoaHoc();
$smarty->assign('ds_namkhoahoc',$ds_namkhoahoc);

$smarty->display('nhom3/xeplop.tpl');   
?>